<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>到货单列表</title>
<link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/pagination.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/xToolbar.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/jquery-impromptu.css" rel="stylesheet"
	type="text/css" />
</head>
<body>
	<div id="toolbar"></div>
	<form id="listForm"
		action="<%=path%>/purchase/arriveOrder/listPagination.t4m"
		method="post">
		<table id="titleTable" cellpadding="0" cellspacing="0">
			<tr>
				<td>&nbsp;</td>
				<td><input type="checkbox" id="allBox" />
				</td>
				<td>到货单编号</td>
				<td>到货时间</td>
				<td>采购单编号</td>
				<td>入库状态</td>
				<td>采购日期</td>
				<td>经办人</td>
				<td>审批状态</td>
				<td>操作</td>
			</tr>
		</table>
		<table id="dataTable" cellpadding="0" cellspacing="0">
			<s:iterator id="arriveOrder" value="page.list" status="i">
				<tr class="row" ondblclick="viewOrder('<s:property value="#arriveOrder.id"/>')">
					<td class="num"><s:property value="#i.index+1" />
					</td>
					<td class="box">
         	  <s:if test="#arriveOrder.auditState != 2">
					<input type="checkbox" name="idList"
						value="<s:property value="#arriveOrder.id"/>" />
              </s:if></td>
					<td><span><s:property value="#arriveOrder.code" />
					</span>
					</td>
					<td><span><s:date name="#arriveOrder.orderDate"
								format="yyyy-MM-dd HH:mm" />
					</span>
					</td>
					<td><span><s:property
								value="#arriveOrder.purchaseOrder.code" />
					</span>
					</td>
					<td><s:property
							value="@org.jxc.vo.KeyValue@getHtml(@org.jxc.constants.JXCString@STORE_STATE, #arriveOrder.storeState)" />
					</td>
					<td><span><s:date
								name="#arriveOrder.purchaseOrder.orderDate" format="yyyy-MM-dd" />
					</span>
					</td>
					<td align="center"><span><s:property
								value="#arriveOrder.creator.realName" />
					</span>
					</td>
					<td><s:property
							value="@org.jxc.vo.KeyValue@getHtml(@org.jxc.constants.JXCString@AUDIT_STATE, #arriveOrder.auditState)" />
					</td>
					<td align="center"><s:if test="#arriveOrder.auditState == 0 || #arriveOrder.auditState == 3">
							<a
								href="javascript:applyBill('<s:property value="#arriveOrder.id"/>')">提交申请</a>
						</s:if> <s:elseif
							test="#arriveOrder.auditor.id == #session['LoginBean'].user.id && #arriveOrder.auditState == 1">
							<a
								href="javascript:auditBill('<s:property value="#arriveOrder.id"/>',2)">同意</a>
							<a
								href="javascript:auditBill('<s:property value="#arriveOrder.id"/>',3)">驳回</a>
						</s:elseif> <s:elseif
							test="#arriveOrder.auditState == 2 && #arriveOrder.storeState == 0 && @org.team4.util.Meta@getOperate(\"menuStock_view\")==\"T\"">
							<a
								href="javascript:inStock('<s:property value="#arriveOrder.id"/>')">生成入库单</a>
						</s:elseif> &nbsp;</td>
				</tr>
			</s:iterator>
		</table>
		<s:include value="/share/pagebar.jsp" />
	</form>

	<script src="<%=path%>/js/core.js" type="text/javascript"></script>
	<script src="<%=path%>/js/share.js" type="text/javascript"></script>
	<script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
	<script src="<%=path%>/js/Grid.js" type="text/javascript"></script>
	<script src="<%=path%>/js/BoxSelect.js" type="text/javascript"></script>
	<script src="<%=path%>/js/xToolbar.js" type="text/javascript"></script>
	<script src="<%=path%>/js/xToolbar.items.js" type="text/javascript"></script>
	<script src="<%=path%>/js/jquery-impromptu.js" type="text/javascript"></script>
	<script type="text/javascript">
    $(document).ready(function(){
      
      new Toolbar({
        id: '1',
        renderTo : 'toolbar',
        icon: '../../image/op.gif',
        items : [{
          type : 'button',
          text : '修改',
          useable : '<s:property value="@org.team4.util.Meta@getOperate(\"arriveOrder_edit\")"/>',
          position: {
            a: '-20px 0px',
            b: '-20px -120px'
          },
          handler : function(){
            if(getFirstID()) {
              top.arriveOrder.edit(getFirstID());
            }
          }
        },'-',{
	          type : 'button',
	          text : '删除',
	          position: {
	            a: '-40px 0px',
	            b: '-40px -120px'
	          },
	          useable : '<s:property value="@org.team4.util.Meta@getOperate(\"arriveOrder_delete\")"/>',
	          handler : function(){
	        	  if(getFirstID())
	              {
	                var txt = '是否删除该信息？';
	                $.prompt(txt,{
	                  buttons:{删除:true,取消:false},
	                  callback: function(v,m) {
	                    if(v) {
	                      document.getElementById('listForm').action = '<%=path%>/purchase/arriveOrder/delete.t4m';
	                      document.getElementById('listForm').submit();
	                    }
	                  }
	                });
	              }
	          }
	        }]
      });
      
      new Grid({
        titleTable:'titleTable',
        dataTable:'dataTable',
        widths : [30,24,100,150,100,100,100,100,100],
        height : function(){return getGridHeight({toolbarId:'toolbar',hasPage:true});}
      });
      
      new BoxSelect({
        allId : 'allBox',
        boxName : 'idList'
      });
      
      loadReady();
    });
    function viewOrder(id) {
  	  top.arriveOrder.view(id);
    }
    function inStock(arriveOrderId) {
        top.inOrder.add(0,arriveOrderId);
      }
    function applyBill(arriveOrderId) {
    	document.getElementById("listForm").action = "<%=path%>/purchase/arriveOrder/apply.t4m?arriveOrderId=" + arriveOrderId;
    	document.getElementById("listForm").submit();
    }
    function auditBill(arriveOrderId,result) {
    	document.getElementById("listForm").action = "<%=path%>/purchase/arriveOrder/audit.t4m?arriveOrderId="
				+ arriveOrderId + "&auditState=" + result;
		document.getElementById("listForm").submit();
		}
	</script>
</body>
</html>